package com.zcj.demo.user.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.zcj.demo.domain.AbstractAuditingEntity;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

/**
 * User
 *
 * @author 自动生成
 * @date 2020-10-13 16:02:43
 */
@Entity
@Table(name = "user")
public class UserDO extends AbstractAuditingEntity implements UserDetails {

	/**
	 * 用户名
	 */
	@Column(name = "user_name")
	private String username;

	/**
	 * 密码
	 */
	@Column(name = "password")
	private String password;

	/**
	 * 真实姓名
	 */
	@Column(name = "name")
	private String name;

	/**
	 * 头像（网址）
	 */
	@Column(name = "avatar")
	private String avatar;

	/**
	 * 邮箱
	 */
	@Column(name = "email")
	private String email;

	/**
	 * 手机号
	 */
	@Column(name = "phone")
	private String phone;

	/**
	 * 手机号
	 */
	@Column(name = "access")
	private String access;

	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {
		return new ArrayList(Arrays.asList(this.access));
	}

	@Override
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Override
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Override
	@JsonIgnore
	public boolean isAccountNonExpired() {
		return false;
	}

	@Override
	@JsonIgnore
	public boolean isAccountNonLocked() {
		return false;
	}

	@Override
	@JsonIgnore
	public boolean isCredentialsNonExpired() {
		return false;
	}

	@Override
	@JsonIgnore
	public boolean isEnabled() {
		return false;
	}
	
	public String getName() {
		return this.name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public String getAvatar() {
		return this.avatar;
	}
	
	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}
	
	public String getEmail() {
		return this.email;
	}
	
	public void setEmail(String email) {
		this.email = email;
	}
	
	public String getPhone() {
		return this.phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getAccess() {
		return access;
	}

	public void setAccess(String access) {
		this.access = access;
	}

	@Override
	public String toString() {
		return "UserDO{" +
			", userName='" + username +'\'' +
			", password='" + password +'\'' +
			", name='" + name +'\'' +
			", avatar='" + avatar +'\'' +
			", email='" + email +'\'' +
			", phone='" + phone +'\'' +
			", id='" + id + '\'' +
		'}';
	}
}
